import { defineStore } from "pinia";
//pinia仓库写法：组合式API、选项式API
import { reqHospitalDetail, reqHospitalDepartment } from "@/api/hospital";
import type { DetailState } from "./interface";
// 引入详情数据的ts类型
import type { HospitalDetailResponseData, HospitalDetail, DepartmentResponseData, DepartmentArr } from "@/api/hospital/type";
const useDetailStore = defineStore('Detail', {
    state: (): DetailState => {
        return {
            // 医院详情的数据
            hospitalInfo: ({} as HospitalDetail),
            departmentArr: []
        }
    },
    actions: {
        // 获取医院详情的方法
        async getHospital(hoscode: string) {
            let result: HospitalDetailResponseData = await reqHospitalDetail(hoscode);
            if (result.code == 200) {
                this.hospitalInfo = result.data;
            }
        },
        // 获取某一个医院科室数据的方法
        async getDepartment(hoscode: string) {
            let result: DepartmentResponseData = await reqHospitalDepartment(hoscode);
            if (result.code == 200) {
                this.departmentArr = result.data;
            }
        }
    },
    getters: {

    }
});
//获取仓库的方法对外暴露
export default useDetailStore;